﻿@model VM_ChangePasswd
@{
    Layout = null;
}
<!DOCTYPE HTML>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no,minimum-scale=1,maximum-scale=1,viewport-fit=cover">
    <title>@ViewBag.SysName</title>
    <script src="~/lib/jquery-1.12.4.min.js" asp-append-version="true"></script>
    <script src="~/lib/math-6.1.0.min.js" asp-append-version="true"></script>
    <!-- 引入样式文件 -->
    <link rel="stylesheet" href="~/css/index.css" rel="stylesheet" />
    @*     <link rel="stylesheet"
          href="https://cdn.jsdelivr.net/npm/vant@2.2/lib/index.css" /> *@
    <!-- 引入 Vue 和 Vant 的 JS 文件 -->
    <script src="~/js/vue.min.js"></script>
    <script src="~/js/vant.min.js"></script>
    @*     <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vant@2.2/lib/vant.min.js"></script> *@
    <script src="~/js/app.js"></script>

    <script>
        var globalData = {
            modules: [],
            user: {},
            baseUrl: '@(Context.Request.PathBase)',
            todoList: [],
            todoIndex:0,
            loginUrl: '@(Url.Action("MobileLogin", "Sys_User"))',
        };
    </script>
    <style>
        html {
            background-color: #f7f7f7;
        }

        #app {
            padding-top: 46px;
            padding-bottom: 60px;
        }

        .van-doc-demo-block {
            padding: 0 16px;
        }

        .van-doc-demo-block__title {
            margin: 0;
            padding: 16px 0;
            color: #323233;
            font-weight: normal;
            font-size: 14px;
        }

        .bottombutton {
            padding: 10px;
        }
    </style>
</head>
<body>
    <div id="app">
        <van-nav-bar title="修改密码"
                     :fixed="true"
                     left-arrow
                     @@click-left="goBack">
        </van-nav-bar>
        <div class="page">
            <van-cell-group>
                <van-field v-model="model.oldpasswd" type="password" label="原密码" placeholder="请输入原密码"></van-field>
                <van-field v-model="model.newpasswd" type="password" label="新密码" @@input="inputChange" placeholder="请输入新密码"></van-field>
                <van-field v-model="confirmpasswd" type="password" label="确认密码" @@input="inputChange" placeholder="请输入确认密码" :error="error"></van-field>
            </van-cell-group>
            <div class="bottombutton">
                <van-button type="primary" block @@click="login" :disabled="logging">修 改</van-button>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        var modelJson=@(Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model, new Newtonsoft.Json.JsonSerializerSettings()
                  {
                      DateFormatString = "yyyy-MM-dd HH:mm:ss"
                  })));
        var modelData = $.extend(modelJson, {
        });
        var pageApp = new Vue({
             el: '#app',
                data: {
                    model: modelData,
                    confirmpasswd:'',
                    error:false,
                    logging: false
                },
                methods: {
                    goBack(){
                        window.location.href = '@(Url.Action("MobileMy", "Home"))';
                    },
                    inputChange(){
                        const _this=this;
                        if(_this.model.newpasswd!=_this.confirmpasswd){
                            _this.error=true;
                        }
                        else{
                            _this.error=false;
                        }
                    },
                    login: function (e) {
                        const _this=this;
                        if(!_this.model.oldpasswd||_this.model.oldpasswd.length<1)
                        {
                            vant.Toast('请输入原密码');
                            return;
                        }
                        if(!_this.model.newpasswd||_this.model.newpasswd.length<1)
                        {
                            vant.Toast('请输入原密码');
                            return;
                        }
                        if(!_this.confirmpasswd){
                            _this.error=true;
                            return;
                        }
                        _this.logging = true;
                        utils.ajaxPost('@Url.Action("ChangePasswd", "Sys_User")', _this.model, function (resp) {
                            _this.logging = false;
                            location.href='@Url.Action("MobileLogin", "Sys_User")';
                        }, function (msg) {
                            _this.logging = false;
                            vant.Toast(msg || "修改密码失败，请检查参数或稍后再试");
                        });
                    }
                },
        });
    </script>
</body>
</html>